package com.itwn.controller;

import com.itwn.result.ResponseResult;
import com.itwn.service.PermissionService;
import com.itwn.vo.PermissionsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @topic:
 **/
@RestController
@RequestMapping("permission")
@CrossOrigin
public class PermissionController {

    @Autowired
    PermissionService permissionService;

    @GetMapping("/list")
    public ResponseResult findAll(){
        List<PermissionsVo> permissionsVoList = permissionService.findAllPermissionVo();
        ResponseResult<List<PermissionsVo>> result = new ResponseResult<>();
        if(permissionsVoList.size()>0){
            result.setCode(200);
            result.setMsg("查询成功");
            result.setData(permissionsVoList);
        }else {
            result.setCode(103);
            result.setMsg("查询失败");
        }
        return result;
    }
}
